Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve msys2 compatibility #114

Merged
merged 39 commits into from
Sep 20, 2024

Conversation

ptahmose
Copy link
Contributor

@ptahmose ptahmose commented Sep 20, 2024

Description

  • control whether "Windows.h" is included (and Win32-API used) from CMake by introducing a new flag "LIBCZI_HAVE_WIN32_API"
  • detect msys2-environment as "Win32-API-platform" (although CMake reports UNIX).
  • add required link-dependencies (since linking Windows-libraries is not handled automatically with msys2 etc.).
  • miscellaneous cosmetic improvements

Fixes #113

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

locally, building under msys2 and other platforms

Checklist:

  • I followed the Contributing Guidelines.
  • I did a self-review.
  • I commented my code, particularly in hard-to-understand areas.
  • I updated the documentation.
  • I updated the version of libCZI following Versioning of libCZI depending on the type of change
    • Bug fix -> PATCH
    • New feature -> MINOR
    • Breaking change -> MAJOR
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.

Introduce `libCZI_WINDOWSAPIAVAILABLE` to detect Windows-based build environments (WIN32, CYGWIN, MSYS, MINGW). Update `CMakeLists.txt` to set this variable and add messages indicating Windows API availability. Configure `libCZI_Config.h` to include `LIBCZI_WINDOWSAPI_AVAILABLE` macro.

Replace `_WIN32` with `LIBCZI_WINDOWSAPI_AVAILABLE` for conditional compilation in multiple files: `StreamImpl.cpp`, `StreamImpl.h`, `windowsfileinputstream.cpp`, `windowsfileinputstream.h`, `decoder_wic.cpp`, `decoder_wic.h`, `libCZI.h`, `libCZI_Site.cpp`, and `utilities.cpp`.

Ensure Windows-specific code is conditionally compiled based on `LIBCZI_WINDOWSAPI_AVAILABLE`, enhancing portability and maintainability.
Removed `stdafx.h` includes from multiple source files and deleted `stdafx.cpp`, `stdafx.h`, `targetver.h`, and `platform_defines.h`. Updated `CMakeLists.txt` to replace platform-specific checks with `LIBCZI_HAVE_WIN32_API` and set `CZICMD_WINDOWSAPIAVAILABLE` accordingly. Adjusted `CMakeLists.txt` to conditionally link Windows libraries and updated the `RapidJSON` Git tag. Replaced platform-specific macros with `CZICMD_WINDOWSAPI_AVAILABLE` in various source files. Added necessary includes to `consoleio.h`. Removed `#pragma once` and other preprocessor directives from multiple files.
@ptahmose ptahmose added the cla Contributor License Agreement sent to Admin label Sep 20, 2024
The `CMakeLists.txt` file now includes a check to determine if the build is targeting a Windows platform and sets the `LIBCZI_HAVE_WIN32_API` variable accordingly. In `libCZI_Lib.cpp`, the preprocessor directive has been updated to use the new `LIBCZI_HAVE_WIN32_API` variable to conditionally compile the appropriate implementation of `CreateInputOutputStreamForFile`.
Set LIBCZI_BUILD_PREFER_EXTERNALPACKAGE_RAPIDJSON to OFF to ensure automatic download and build of RapidJSON. Added comments to clarify RapidJSON as a header-only library and noted issues with version 1.1.0 on GCC 14.2 with msys2. Using a later version from the master branch (commit 7c73dd7de7c4f14379b781418c6e947ad464c818).
Replaced the LINUXENV-based conditional inclusion of `libgen.h` with a more standard preprocessor check for non-Windows environments using `_WIN32`. This ensures `libgen.h` is included only when not compiling on Windows, improving code clarity and portability.
Copy link

codecov bot commented Sep 20, 2024

Codecov Report

Attention: Patch coverage is 44.44444% with 5 lines in your changes missing coverage. Please review.

Project coverage is 65.50%. Comparing base (900cada) to head (691857b).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
Src/libCZI/decoder_wic.cpp 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #114      +/-   ##
==========================================
- Coverage   65.51%   65.50%   -0.01%     
==========================================
  Files          86       86              
  Lines       10892    10893       +1     
==========================================
  Hits         7136     7136              
- Misses       3756     3757       +1     
Flag Coverage Δ
windows-latest 65.50% <44.44%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ptahmose ptahmose marked this pull request as ready for review September 20, 2024 17:31
@ptahmose ptahmose requested a review from a team September 20, 2024 17:31
@ptahmose ptahmose mentioned this pull request Sep 20, 2024
Copy link
Contributor

@m-aXimilian m-aXimilian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!

Src/CZICmd/consoleio.h Show resolved Hide resolved
Src/libCZI/CMakeLists.txt Show resolved Hide resolved
@ptahmose ptahmose merged commit ae6130d into ZEISS:main Sep 20, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla Contributor License Agreement sent to Admin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Building in MSYS2 fails
2 participants